package com.zork.cmdb.webapi.domain.mapper;

import com.zork.cmdb.webapi.domain.dbo.ModuleRelationshipDO;
import com.zork.cmdb.webapi.domain.dto.RelationshipInstanceDTO;
import com.zork.cmdb.webapi.domain.vo.RelationshipInstanceVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author chenjh
 * @date 2018/5/24
 * @description
 */
@Mapper
public interface RelationshipInstanceMapper {

    RelationshipInstanceMapper MAPPER = Mappers.getMapper(RelationshipInstanceMapper.class);

    RelationshipInstanceDTO getDTO(ModuleRelationshipDO moduleRelationshipDO);

    List<RelationshipInstanceDTO> getDTOList(List<ModuleRelationshipDO> moduleRelationshipDOList);

    @Mappings({
            @Mapping(source = "relationshipInstanceDTO.selectedModule.moduleName", target = "selectedModule"),
            @Mapping(source = "relationshipInstanceDTO.ralationshipModule.moduleName", target = "ralationshipModule"),
            @Mapping(source = "relationshipInstanceDTO.ralationshipType.ralationshipTypeName", target = "ralationshipTypeName"),
            @Mapping(source = "relationshipInstanceDTO.ralationshipGroup.ralationshipGroupName", target = "ralationshipGroupName"),
    })
    RelationshipInstanceVO getVO(RelationshipInstanceDTO relationshipInstanceDTO);

    List<RelationshipInstanceVO> getVOList(List<RelationshipInstanceDTO> relationshipInstanceDTOList);
}
